package com.example.utils;

/*
 * @className: SerializableUtils
 * @author: chentao
 * @date: 2025/3/20 上午8:35
 * @Version: 1.0
 * @description:
 */
public class SerializableUtils {

    /***
     * 反序列化成对象
     * @param bytes
     * @return
     */
    public static Object deserialize(byte[] bytes, Class<?> clazz) throws Exception {
        return ObjectMapperUtils.getDefaultObjectMapper().readValue(bytes, clazz);
    }

    /***
     * 序列化对象
     * @param obj
     * @return
     * @throws Exception
     */
    public static byte[] serialize(Object obj) throws Exception {
        return ObjectMapperUtils.getDefaultObjectMapper().writeValueAsBytes(obj);
    }
}
